package com.autonavi.yunda.yunji.core.engine.handler;

import com.autonavi.yunda.yunji.common.utils.SpringUtil;
import com.autonavi.yunda.yunji.core.service.ICommonTairService;
import com.taobao.tair.DataEntry;
import com.taobao.tair.ResultCode;

import java.util.List;
import java.util.Map;

/**
 * @author cizhong.wcs
 * @date 2023/8/3 16:11
 */
public class TairHandler {
    public static ResultCode put(String dbName, String key, String value, int version, int expired) {
        ICommonTairService instance = SpringUtil.getBean(ICommonTairService.class);
        return instance.put(dbName, key, value, version, expired);
    }

    public static String get(String dbName, String key) {
        ICommonTairService instance = SpringUtil.getBean(ICommonTairService.class);
        return instance.get(dbName, key);
    }

    public static boolean invalid(String dbName, String key) {
        ICommonTairService instance = SpringUtil.getBean(ICommonTairService.class);
        return instance.invalid(dbName, key);
    }

    public static List<DataEntry> mget(String dbName, List<String> key) {
        ICommonTairService instance = SpringUtil.getBean(ICommonTairService.class);
        return instance.mget(dbName, key);
    }


    public static Map<String, Integer> mgetInt(String dbName, List<String> key) {
        ICommonTairService instance = SpringUtil.getBean(ICommonTairService.class);
        return instance.mgetInt(dbName, key);
    }


    public static int incTime(String dbName, String key, Integer expireTime) {
        ICommonTairService instance = SpringUtil.getBean(ICommonTairService.class);
        return instance.incTime(dbName, key, expireTime);
    }


    public static List<DataEntry> tairBatchGet(String dbName, List<String> keys, int groupSize) {
        ICommonTairService instance = SpringUtil.getBean(ICommonTairService.class);
        return instance.tairBatchGet(dbName, keys, groupSize);
    }

}
